import { nextTick } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

import { useWindowStore } from '@/store/window'
import { importRoute } from '@/utils/import-route'

const routes: RouteRecordRaw[] = [
  { path: '/', redirect: '/login' },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue')
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/home.vue'),
    children: []
  }
]

const router = createRouter({
  routes,
  history: createWebHashHistory()
})

// router.beforeEach((to, form) => {
//   if (to.path === '/' || to.path == '/home' || to.path === '/login') {
//     return true
//   } else { //不是根路径，需要刷新会使路由丢失
//       //添加路由
//     const routes = importRoute()
//     routes.forEach(route => {
//       router.addRoute('home', route)
//     })

//   }

// })

export default router
